/**
 * 
 */
package PartEdgeDemo;

import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.HashMap;

import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import y.base.Node;
import y.base.NodeCursor;
import y.view.Graph2D;

/**
 * @author Andreas Lauer
 *  DEPRECATED, braucht man theoretisch nichtmehr
 */
public class DebugInterface {

	private Graph2D g;
//	private HashMap<Node, String> informations;
	private JFrame frame;

	public DebugInterface(Graph2D g) {
		this.g = g;
//		this.informations = informations;
		this.frame = new JFrame("xx Debug Interface xx");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLayout(new BorderLayout());
		frame.setFocusable(true);
		frame.pack();
	}
	
	




	public void createContentPane(HashMap<Node, String> informations) {
		Node[] nodes = this.g.getNodeArray();
		HashMap<Node, ArrayList<Node>> neighbors = new HashMap<Node, ArrayList<Node>>();

		// jedem knoten seine nachbarn zeigen
		for (int i = 0; i < nodes.length; i++) {
			ArrayList<Node> neighborholder = new ArrayList<Node>();
			NodeCursor nc = nodes[i].neighbors();
			for (int j = 0; j < nc.size(); j++) {
				neighborholder.add((Node) nc.current());
				nc.cyclicNext();
			}
			neighbors.put(nodes[i], neighborholder);
		}

		HashMap<Node, String> nodeString = new HashMap<Node, String>();

		for (int i = 0; i < nodes.length; i++) {
			Node v = nodes[i];
			nodeString.put(v,
					(nodes[i] + "   |   " + (int) g.getCenterX(nodes[i]) + "/"
							+ (int) g.getCenterY(v) + "   |   "
							+ neighbors.get(v) + "   |   " + informations
							.get(v)));
		}
		JPanel contentPane = new JPanel();
		contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
		contentPane.add(new JLabel(
				"Node  |   x/y   |   neighbors   |   forceX/forceY   |   #turn   |   #intersections"));
		contentPane
				.add(new JLabel("--------------------"+"---------------------"));
		for (int i = 0; i < nodeString.size(); i++) {
			contentPane.add(new JLabel(nodeString.get(nodes[i])));
		}
		contentPane
				.add(new JLabel("-----------------------------------------"));
		JScrollPane scrPane = new JScrollPane(contentPane);
		scrPane.setFocusable(true);
		frame.add(scrPane, BorderLayout.NORTH);
//		return contentPane;
	}

}
